package com.example.auv_660.autocontrolalgorithm.assistantsensor;

import android.content.Context;
import android.os.BatteryManager;

import com.example.auv_660.MainActivity;

public class BatterySensor {
    private BatteryManager batteryManager;
    private MainActivity mainActivity = MainActivity.getInstance();

    public BatterySensor()
    {
        if (mainActivity != null)
        {
            batteryManager = (BatteryManager) mainActivity.getSystemService(Context.BATTERY_SERVICE);
        }
    }

    public int getCurrentBattery()
    {
        return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
    }

    public void releaseSource()
    {
        if (batteryManager != null)
        {
            batteryManager = null;
        }
    }
}
